<?php
//error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
require_once('./roots.php');
require_once($root_path.'include/inc_environment_global.php');

/**
* CARE2X Integrated Hospital Information System beta 2.0.1 - 2004-07-04
* GNU General Public License
* Copyright 2002,2003,2004,2005,2006 Elpidio Latorilla
* elpidio@care2x.org, 
*
* See the file "copy_notice.txt" for the licence notice
*/

define('LANG_FILE','usuarios.php');
define('NO_2LEVEL_CHK',1);
require_once($root_path.'include/inc_front_chain_lang.php');

require_once($root_path.'include/care_api_classes/class_core.php');
$core=new Core;
require_once($root_path.'include/care_api_classes/class_usuario.php');

$u = new Usuario;
$usuario = $u->getAllInfoObject($login_id);

extract($usuario->FetchRow());
unset($password);
$update = 1;
require_once('usuario-registrar.php');
exit;

/*$thisfile=basename(__FILE__);
$breakfile='interconsulta.php';
$action='interconsulta-save.php'.URL_APPEND.'&update='.$update.'&id='.$id;

$interconsulta = new Interconsulta;
$especialidades = $interconsulta->loadEspecialidades();

$temp = $interconsulta->getAllInfoObject($id);

// echo "<pre>";
// var_dump($temp);
// echo "</pre>";

extract($temp->FetchRow());

$motivoCierre = '<select name="motivo_cierre">';
for ($i = 1; $i < 6; $i++)
{
    $motivoCierre .= "<option value='$i'";
    if ($estado == $i)
    {
        $motivoCierre .= " selected";
    }

    $motivoCierre .= ">$i</option>";
}
$motivoCierre .= "</select>";

$c=1;
if (count($especialidades)){
foreach ($especialidades as $temp)
{
        if($id_especialidad ==$temp["id"]){
    $opts .= '<input type="radio" name="id_especialidad" value="' . $temp["id"] . '" checked>'. $temp["descripcion"];

        }else{
    $opts .= '<input type="radio" name="id_especialidad" value="' . $temp["id"] . '">'. $temp["descripcion"];

        }

        if(!($c % 4)) $opts .='<br>';
        $c++;
}
}

$etnias = $interconsulta->loadEtnias();
$combo = '<select name="etnia"><option value="0">' . $LDSelect . '</option>';
while ($temp=$etnias->FetchRow())
{
        if($etniaValue == $temp["nr"]){
                $combo .= '<option value="'. $temp["nr"] .'" selected>' . $temp["name"] . '</option>';
        }else{
                $combo .= '<option value="'. $temp["nr"] .'">' . $temp["name"] . '</option>';

        }
}
$combo .= '</select>';

$user = $interconsulta->preloadUserInfo($_SESSION['sess_login_userid']);

$files = $interconsulta->seleccionarNombreAdjuntos($id);

$archivos="";

if (count($files))
{
    foreach($files as $file){
            $name = $file['name'];
            $option="menubar=no,width=600,height=6000,resizable=yes,scrollbars=yes";
    
            if (strlen($name))
            {
                    $url="../../modules/interconsulta/include/showImage.php?id=$id&name=$name ";
                    $archivos .= "<a href=\"javascript: window.open('$url','wblabel','$option'); exit;\">$name</a> ";
    
            }
    }
}

if($archivos=='') $archivos="Ninguno.";
else{
	$archivos=substr_replace($archivos,'',(strlen($archivos))-2);
 }


# Start Smarty templating here
/ **
* LOAD Smarty
* /

# Note: it is advisable to load this after the inc_front_chain_lang.php so
# that the smarty script can use the user configured template theme
?>
                <script  language="javascript">
                function forceSave(){
                        document.aufnahmeform.mode.value="forcesave";
                        document.aufnahmeform.submit();
                }

                function showpic(d){
                        if(d.value) document.images.headpic.src=d.value;
                        if(d.value) document.images.headpic.src=d.value;
                }

                function popSearchWin(target,obj_val,obj_name){
                        urlholder="./data_search.php<?php echo URL_REDIRECT_APPEND; ?>&target="+target+"&obj_val="+obj_val+"&obj_name="+obj_name;
                        DSWIN<?php echo $sid ?>=window.open(urlholder,"wblabel<?php echo $sid ?>","menubar=no,width=400,height=550,resizable=yes,scrollbars=yes");
                }

                function popWin(){
                        urlholder="./interconsulta-adjuntar.php<?php echo URL_REDIRECT_APPEND;?>";
                        DSWIN<?php echo $sid ?>=window.open(urlholder,"wblabel<?php echo $sid ?>","menubar=no,width=400,height=150,resizable=yes,scrollbars=yes");
                }

                function chkform(d) {
                        if(d.interconsultante.value==""){//
                                alert("<?php echo $LDPlsEnterIC; ?>");
                                d.apellido_1.focus();
                                return false;
                        }else if(d.establecimiento.value==""){//
                                alert("<?php echo $LDPlsEnterEstablecimiento; ?>");
                                d.establecimiento.focus();
                                return false;
                        }else if(d.id_paciente.value==""){
                                alert("<?php echo $LDPlsEnterIdPaciente; ?>");
                                d.id_paciente.focus();
                                return false;
                        }else if(d.apellido_1.value==""){
                                alert("<?php echo $LDPlsEnterLastName; ?>");
                                d.apellido_1.focus();
                                return false;
                        }else if(d.name_1.value==""){
                                alert("<?php echo $LDPlsEnterFirstName; ?>");
                                d.name_1.focus();
                                return false;
                        }else if(d.sex[0]&&d.sex[1]&&!d.sex[0].checked&&!d.sex[1].checked){
                                alert("<?php echo $LDPlsSelectSex; ?>");
                                return false;
                        }else if(d.motivo.value==""){//
                                alert("<?php echo $LDPlsEnterMotivo; ?>");
                                d.motivo.focus();
                                return false;
                        }else if(d.antecedentes.value==""){//
                                alert("<?php echo $LDPlsEnterAntecedentes; ?>");
                                d.antecedentes.focus();
                                return false;
                        }
                }

<?php
                require($root_path.'include/inc_checkdate_lang.php'); 
?>
                </script>
<?php

require_once($root_path.'gui/smarty_template/smarty_care.class.php');
$smarty = new smarty_care('common');

$smarty->assign('breakfile',$breakfile);
$smarty->assign('action',$action);
$smarty->assign('reg',1);
$smarty->assign('currentUser', $_SESSION['sess_login_userid']);

$smarty->assign('sToolbarTitle',$LDInter);

$smarty->assign('title',$LDEditInter);

$smarty->assign('LDInterconsultante',$LDInterconsultante);
$smarty->assign('sInterconsultanteInput','<input name="interconsultante" type="text" size="35" value="'. $user["name"] . '" readonly>');

$smarty->assign('LDEstablecimiento',$LDEstablecimiento);
$smarty->assign('sEstablecimientoInput','<input name="establecimiento" type="text" size="35" value="'.$establecimiento.'">');

$smarty->assign('LDEspecialidad',$LDEspecialidad);
$smarty->assign('sEpecialidadRadio',$opts);

$smarty->assign('LDPersonData',$LDPersonData);
*/
/* campos para la tabla */
/*
include_once('../../include/inc_date_format_functions.php');
require_once ('../../js/jscalendar/calendar.php');
$calendar = new DHTML_Calendar('../../js/jscalendar/', 'es', 'calendar-system', true);
$calendar->load_files();

$smarty->assign('LDPaciente',$LDCaseNr);
$smarty->assign('sPacienteInput','<input name="id_paciente" type="text" size="35" value="'.$id_paciente.'" readonly>');
$smarty->assign('sPacienteMiniCalendar',"<a href=\"javascript:popSearchWin('paciente')\"><img ".createComIcon($root_path,'b-write_addr.gif','0')."></a>");

$smarty->assign('LDApellido',$LDLastName);
$smarty->assign('sApellidoPacienteInput','<input name="apellido_1" type="text" size="35" value="'.$apellido_1.'">');

$smarty->assign('LDApellido2',$LDLastName2);
$smarty->assign('sApellidoPaciente2Input','<input name="apellido_2" type="text" size="35" value="'.$apellido_2.'">');

$smarty->assign('LDNombre',$LDName);
$smarty->assign('sNombrePacienteInput','<input name="name_1" type="text" size="35" value="'.$name_1.'">');

$smarty->assign('LDNombre2',$LDName2);
$smarty->assign('sNombrePaciente2Input','<input name="name_2" type="text" size="35" value="'.$name_2.'">');

$smarty->assign('LDSexo',$LDSex);
$sCSBuffer='<input id="sexo_paciente_f" name="sex" type="radio" ';
$sCSBuffer .= 'value="f" ';

if($sex=="f") $sCSBuffer.='checked';
$smarty->assign('sFemInput',$sCSBuffer.'>');

$sCSBuffer='<input id="sexo_paciente_m" name="sex" type="radio" ';
$sCSBuffer .= 'value="m" ';

if($sex=="m") $sCSBuffer.='checked';
$smarty->assign('sMasInput',$sCSBuffer.'>');

$smarty->assign('LDFem','Femenino');
$smarty->assign('LDMas','Masculino');

$smarty->assign('LDEstado',$LDStatus);
$sCSBuffer='<input name="estado" type="radio" value="1" ';
if($estado==1) $sCSBuffer.='checked';
$sCSBuffer.='>Consultando &nbsp;<input name="estado" type="radio" value="2" ';
if($estado==2) $sCSBuffer.='checked';
$sCSBuffer.='>Cerrada';

$smarty->assign('LDMotivoCierre',"Motivo del Cierre");
$smarty->assign('sMotivoCierreInput',$motivoCierre);

$smarty->assign('sEstadoInput',$sCSBuffer);

$smarty->assign('LDEtnia',$LDEthnicGroup);
$smarty->assign('sEtniaCombo',$combo);

$listarPaciente ="<a href='../../modules/registration_admission/patient_register_show.php?lang=es&pid=".$id_paciente."&edit=1'><b>Mas datos del paciente</b></a>";
$smarty->assign('LDListarPaciente',$listarPaciente);

$smarty->assign('LDInterData', $LDInterData);

$smarty->assign('LDFecha',$LDDate);
$smarty->assign('sFechaInput','<input name="fecha_hora_consulta" type="text" size="35" readonly value="' . date("d/m/Y H:i:s") . '" value="'.$fecha_hora_consulta.'">');

$smarty->assign('LDMotivo',$LDMotive);
$smarty->assign('sMotivoText','<textarea name="motivo" cols="43" rows="5">'.$motivo.'</textarea>');



$smarty->assign('LDArchivos',"Archivos Adjuntos:");
$smarty->assign('sListaArchtext',$archivos.'<br><input name="listaArchivos" type="text" size="35" readonly>');
$smarty->assign('sFileBrowser',"<a href=\"javascript:popWin()\"><img ".createComIcon($root_path,'b-write_addr.gif','0')."></a>");

$smarty->assign('LDExamenFisico',$LDPhysEx);
$smarty->assign('sExamenFisicoText','<textarea name="examen_fisico" cols="43" rows="5">'.$examen_fisico.'</textarea>');

$smarty->assign('LDPeso',$LDWeight);
$smarty->assign('sPesoInput','<input name="peso" type="text" size="12" maxlength="10" value="'.$peso.'">');

$smarty->assign('LDTalla',$LDSize);
$smarty->assign('sTallaInput','<input name="talla" type="text" size="12" maxlength="10" value="'.$talla.'">');

$smarty->assign('LDAntecedentes',$LDBckgrd);
$smarty->assign('sAntecedentesText','<textarea name="antecedentes" cols="43" rows="5">'.$antecedentes.'</textarea>');

$smarty->assign('pbSubmit','<input type="image" '.createLDImgSrc($root_path,'savedisc.gif','0').'  alt="'.$LDSaveData.'" align="absmiddle">');
$smarty->assign('pbReset','<a href="javascript:document.regform.reset()"><img '.createLDImgSrc($root_path,'reset.gif','0').' alt="'.$LDResetData.'" align="absmiddle"></a>');

$smarty->assign('sMainBlockIncludeFile','interconsulta/registrar_interconsulta.tpl');
*/
/**
* show Template
*/
//$smarty->display('common/mainframe.tpl');
?>